import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

let extend="/admin/";
// require.ensure 分离 打包
//require.ensure([], () => r(require('../layouts/Default/Index.vue')), 'defaultLayout'),

export default new Router({
    routes: [
        {//不认识的路由默认跳转到这个view上
            path: '*',
            name: 'err',
            component: r => {require(['@/components/err/Err.vue'], r)}
        },
        {//后台首页登陆login页
            path: '/',
            name: 'index',
            redirect: { name: `login` }
        },
        {//后台首页登陆login页
            path: `${extend}login`,
            name: 'login',
            component: r => {require(['@/components/login/Login.vue'], r)}
        },
        {
            path: `${extend}`,
            component: r => {require(['@/components/public/index.vue'], r)},
            children:[
                {
                    path:'',//默认的路由 ,进行跳转
                    redirect: { name: `welcome` }
                },
                {
                    path:'welcome',
                    name:'welcome',
                    component: r => {require(['@/components/welcome/Welcome.vue'], r)}
                },
                {
                    path:'addStudents',
                    name:'addStudents',
                    component: r => {require(['@/components/students/addStudents.vue'], r)}
                },
            ]
        },

    ]
})
